<template>
    <div>
        <table class="table table-bordered">
            <tbody>
                <tr>
                    <td>房型</td>
                    <td>
                        <select v-model="quinfo.fangName">
                            <option value="标准间">标准间</option>
                            <option value="豪华单人">豪华单人</option>
                            <option value="山景房">山景房</option>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td>房间号码</td>
                    <td>
                        <input type="text" v-model="quinfo.hao">
                    </td>
                </tr>
                <tr>
                    <td>房号描述:</td>
                    <td>
                        <textarea v-model="quinfo.miao"></textarea>
                    </td>
                </tr>
                <tr>
                    <td>状态</td>
                    <td>
                        <input
              type="radio"
              name="shi"
              value=0
              v-model="quinfo.state"
            />上架
            <input
              type="radio"
              name="shi"
              value=1
              v-model="quinfo.state"
            />下架
                    </td>
                </tr>
                <tr>
             
                    <td>
                        <input type="button" value="添加" @click="add">
                    </td>
                </tr>
            </tbody>
        </table>
    </div>
</template>

<script setup lang="ts">
import router from '@/router';
import axios from 'axios';
import {reactive,ref,onMounted} from 'vue'
import {useRoute,useRouter} from 'vue-router'
let quinfo=reactive({
  "fangName": "",
  "hao": "",
  "miao": "",
  "state": 0,
  "isDelete": false
})
const add=()=>{
    if(quinfo.fangName==""){
        alert("房型不能为空!");
        return;
    }
    if(quinfo.miao==""){
        alert("描述不能为空!");
        return;
    }
    axios({
        url:'https://localhost:7203/api/Fang/Add',
        method:'post',
        data:quinfo
    })
    .then((res)=>{
        console.log(res);
        alert("成功!");
        router.push("/fnagShow")
    })
    .catch((err)=>{
        console.log(err);
    })
}
</script>

<style scoped>

</style>